﻿using ExcelConfig.helpers;
using System;

namespace ExcelConfig.Template
{
    public class ExcelTemplateFile
    {
        internal string Path { get; set; }
        internal string FileName { get; set; }
        internal string TemplatePath { get { return System.IO.Path.Combine(Path, FileName); } }
        public ExcelTemplateFile(string path, string filename)
        {
            this.Path = path;
            this.FileName = filename;
        }
        public ExcelTemplateFile(string path)
        {
            this.Path = helper.read_before_path(path);
            this.FileName = helper.read_filename(path);
        }

        /// <summary>
        /// 填充数据，并输出
        /// </summary>
        /// <param name="path"></param>
        /// <param name="obj"></param>
        public void TemplateOut(object obj, string path)
        {
            MiniExcel.SaveAsByTemplate(path, this.TemplatePath, obj);
        }
    }
}
